{include file="public/header" /}
{load href="__PLUGINS__bootstrap/bootstrap-table.min.css"}
{load href="__PLUGINS__bootstrap/bootstrap-table.min.js"}
<style type="text/css">
    #des, #des input {
        width: 40px;
        text-align: center;
    }
    #id {
        width: 78px;
    }
    .bs-checkbox {
        width: 36px;
        height: 40px
    }
    .fixed-table-toolbar .columns, .fixed-table-toolbar .search {
        margin-left: 0px;
        margin-top: 0px
    }
    #title span {
        float: right;
        margin-left: 3.333px;
    }
    .search {
        margin-bottom: 0px !important;
    }
    .asdlkjasd {
        background: #1ab394;
        color: #fff
    }
    #title {
        position: relative;
        padding-right: 50px;
    }
    #title span {
        position: absolute;
        top: 12px;
        right: 10px;
    }
    .userid-btn:hover {
        background-color: #1ab394;
        color: white;
    }
    .fixed-table-toolbar form {
        display: flex;
        justify-content: space-between;
    }
    .fixed-table-toolbar button {
        margin-left: 10px;
    }
</style>
<body class="gray-bg">
<div class="wrapper wrapper-content {:config('adminClass.main')}">
    <div class="ibox float-e-margins">
        {include file="public/tophead"}
        {include file="public/top" /}
        <p id="hint" style="color:blue;margin-left:18px;margin-bottom: 15px;">请点击用户id按钮后显示统计数据</p>
        <div class="ibox-content">
            {include file="public/topsection"}
            <div class="row row-lg">
                <div class="col-sm-12">
                    <div class="fixed-table-toolbar">
                        <form method="get" action="">
                            <div class="pull-left search" style="display: flex;">
                                {eq name='isadmin' value='1'}
                                <div>
                                    {foreach $superdai as $k=>$v }
                                    <button class="btn userid-btn {eq name='$v.bind_uid' value='$currentuid'}asdlkjasd{/eq}" data-userid="{$v.bind_uid}">{$v.bind_uid}（{$v.sdname}）</button>
                                    {/foreach}
                                </div>
                                <input type="hidden" name="userid" id="userid" value="{$currentuid}">
                                {/eq}
                                <input name="start" type="text" id="start" class="form-control layui-input" value="{$start}" placeholder=" # 起始时间" autocomplete="off" style="height:34px;width:180px;margin:0 10px;">
                                <input name="end" type="text" id="end" class="form-control layui-input" value="{$end}" placeholder=" # 结束时间" autocomplete="off" style="height:34px;width:180px;margin:0 10px;">
                                <div class="pull-right search">
                                    <button style="border-radius:0px; border:1px solid #e5e6e7;" class="btn btn-default btn-outline" type="submit">搜索</button>
                                    <button style="border-radius:0px; border:1px solid #e5e6e7;" class="btn btn-default btn-outline" type="button" onclick="reloadPageWithoutParams()">清空</button>
                                </div>
                            </div>
                        </form>
                    </div>

                    <div style="display:block;clear: both;"></div>
                    <style>
                        .search{
                            position: relative;
                            left:-10px;
                        }
                        .example{
                            margin-top:20px;
                            margin-bottom: 300px;
                        }
                        .example p{
                            line-height: 30px;
                        }
                    </style>
                      <p style="color:red;line-height:25px;">说明：<br/>1.为确保统计数据的准确性，请于次日 0 时进行数据统计，例如 6 月 8 日0时统计 6 月 7 日 00:00:00-23:59:59 的时段数据，并务必截图保存。若在其他时间段查询，可能因上下级关系解绑等因素影响，导致统计数据出现较大波动，自然日的起止时间是00:00:00至23:59:59。<br/>2.不同的超级代理间可能存在上下级关系，充值金额合计会超出系统充值金额，请注意核对。<br/>3.若统计数据出现明显不对的情况，请停止后续积分发放工作，及时和相关同事进行沟通。</p>
                    <div class="example">
                        <p>充值金额：{$totalRecharge}元</p>
                        <p>会员充值：{$totalVipRecharge}元</p>
                        <p>会员总数：{$memberCount}人</p>
                        {if condition="$start eq '' and $end eq ''"}
                        <p style="color:blue;">今日新增：{$todayNewMembers}人</p>
                        <p style="color:blue;">今日充值金额：{$todayRecharge}元</p>
                        <p style="color:blue;">今日会员充值：{$todayVipRecharge}元</p>
                        <hr>
                        <p style="color:blue;">昨日新增：{$yesdayNewMembers}人</p>
                        <p style="color:blue;">昨日充值金额：{$yesdayRecharge}元</p>
                        <p style="color:blue;">昨日会员金额：{$yesdayVipRecharge}元</p>
                        {/if}
                    </div>
                </div>
            </div>
            <hr>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script type="text/javascript">
    $(document).ready(function () {
        layui.use(['laydate'], function () {
            var laydate = layui.laydate;

            laydate.render({
                elem: '#start' //指定元素
                , type: 'datetime'
                , trigger: 'click'
            });

            laydate.render({
                elem: '#end' //指定元素
                , type: 'datetime'
                , trigger: 'click'
            });

            $('.userid-btn').click(function () {
                var userid = $(this).data('userid');
                $('#userid').val(userid);
                $('#hint').text('正在加载用户' + userid + '的统计数据，请稍候...');

                // 主动提交表单并携带当前时间段参数
                $('form').submit();
            });

            $('form').submit(function (e) {
                var action = $(this).attr('action');
                var formData = $(this).serialize(); // 序列化所有表单参数

                // 处理URL参数合并
                if (formData) {
                    if (action.indexOf('?') === -1) {
                        action += '?' + formData;
                    } else {
                        action += '&' + formData;
                    }
                }

                // 更新表单action为包含所有参数的URL
                $(this).attr('action', action);
                return true;
            });
        });
    });
</script>
<script>
    /**
     * 重载当前页面（不带任何参数）
     */
    function reloadPageWithoutParams() {
        const baseUrl = window.location.origin + window.location.pathname;
        window.location.href = baseUrl;
    }
</script>